package com.my.controller;


import cn.hutool.core.util.StrUtil;
import com.my.pojo.Branch;
import com.my.service.BranchService;
import com.my.service.impl.BranchServiceImpl;
import com.mysql.cj.util.StringUtils;


import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/branchServlet")
public class BranchServlet extends HttpServlet {
    BranchService branchService = new BranchServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String branchId = req.getParameter("branchId");
        if(StrUtil.isNotEmpty(branchId)){
            Integer id = Integer.parseInt(branchId);
            Branch branch = branchService.getBranchById(id);

        }else {
            Integer id = Integer.parseInt(branchId);
            Branch branch = branchService.getBranchById(id);
            req.setAttribute("branch",branch);
            req.getRequestDispatcher("branch.jsp").forward(req,resp);
        }
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
